package com.qf.flash.mvp.presenter;


import com.qf.flash.http.HttpManager;
import com.qf.flash.model.PhotoLinesBean;
import com.qf.flash.mvp.contract.MyPhoneLinesContract;
import com.qf.flash.utils.AppToast;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.exception.ApiException;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class MyPhotoLinesPresent extends BasePresenter<MyPhoneLinesContract.View> implements MyPhoneLinesContract.Presenter {
    @Override
    public void getPhotoLines(String id) {
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_PHONELINES(id)
                .compose(RxUtils.<List<PhotoLinesBean>>handleResult())
                .compose(RxUtils.<List<PhotoLinesBean>>io_main())
                .subscribeWith(new BaseSubscriber<List<PhotoLinesBean>>(mRootView) {
                    @Override
                    public void onSuccess(List<PhotoLinesBean> beans) {
                        mRootView.setUi(beans);
                    }

                    @Override
                    public void onError(ApiException e) {
                        super.onError(e);
                        AppToast.showToast("eeee");
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        AppToast.showToast("onComplete");
                    }
                })

        );
    }
}
